//
//  SEGUserHouseListModel.m
//  SEGUhomeStandard
//
//  Created by Clavis on 2019/1/17.
//  Copyright © 2019 刘山. All rights reserved.
//

#import "SEGUserHouseListModel.h"

@implementation SEGUserHouseListModel

- (instancetype)initWithDictionary:(NSDictionary *)dictionary
{
    self = [super init];
    if (self) {
        [self setValuesForKeysWithDictionary:dictionary];
    }
    return self;
}

- (instancetype)init {
    self = [super init];
    if (self) {
        self.houseId = @"";
        self.houseName = @"";
        self.communityId = @"";
        self.communityName = @"";
        self.buildId = @"";
        self.unitId = @"";
        self.roomNo = @"";
        self.custId = @"";
        self.custType = @"";
    }
    return self;
}

+ (instancetype)initWithDictionary:(NSDictionary*)dictionary {
    return [[self alloc] initWithDictionary:dictionary];
}

- (void)setValue:(id)value forUndefinedKey:(NSString*)key {
}

- (void)setHouseId:(NSString *)houseId {
    _houseId = [[SEGUtils ValueToString:houseId] copy];
}

- (void)setHouseName:(NSString *)houseName {
    _houseName = [[SEGUtils ValueToString:houseName] copy];
}

- (void)setCommunityId:(NSString *)communityId {
    _communityId = [[SEGUtils ValueToString:communityId] copy];
}

- (void)setCommunityName:(NSString *)communityName {
    _communityName = [[SEGUtils ValueToString:communityName] copy];
}

- (void)setBuildId:(NSString *)buildId {
    _buildId = [[SEGUtils ValueToString:buildId] copy];
}

- (void)setUnitId:(NSString *)unitId {
    _unitId = [[SEGUtils ValueToString:unitId] copy];
}

- (void)setRoomNo:(NSString *)roomNo {
    _roomNo = [[SEGUtils ValueToString:roomNo] copy];
}

- (void)setCustId:(NSString *)custId {
    _custId = [[SEGUtils ValueToString:custId] copy];
}

- (void)setCustType:(NSString *)custType {
    _custType = [[SEGUtils ValueToString:custType] copy];
}

- (void)encodeWithCoder:(NSCoder *)encoder {
    unsigned int count = 0;
    objc_property_t *propertes = class_copyPropertyList([self class], &count);
    for (int i=0; i<count; i++) {
        const char *propertyName = property_getName(propertes[i]);
        NSString *name = [NSString stringWithUTF8String:propertyName];
        id value = [self valueForKey:name];
        [encoder encodeObject:(value)?value:@"" forKey:name];
    }
}

- (id)initWithCoder:(NSCoder *)decoder {
    if (self = [super init]) {
        unsigned int count =0;
        objc_property_t *propertes = class_copyPropertyList([self class], &count);
        for (int i = 0; i < count; i++) {
            const char *propertyName = property_getName(propertes[i]);
            NSString *name = [NSString stringWithUTF8String:propertyName];
            id value = [decoder decodeObjectForKey:name];
            [self setValue:(value)?value:@"" forKey:name];
        }
        
    }
    return self;
}

- (NSString *)description{
    return [self yy_modelDescription];
}

- (NSString *)fullHouseName {
    return [NSString stringWithFormat:@"%@%@", (self.communityName ?: @""), (self.houseName ?: @"")];
}

@end
